#ifndef TERMINAL_H
#define TERMINAL_H	
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
//#include <stdio.h>
#include <stdbool.h>
#include "menu.h"


/*	+-----------------------------+
	|	      Header	80x4	  |
	+-----------------------------+
	|MENU	|	STATUS			  |
	|		|					  |
	|		|					  |
	+-------+---------------------+
*/

//clock
volatile uint8_t seconds;
volatile uint8_t minutes;
volatile uint8_t hours;	

extern bool reprint;

#define TERMSIZE_X 65
#define TERMSIZE_Y 18 

#define FRAMEPOS_X 3
#define FRAMEPOS_Y 3

#define IONAMEMAXLENGTH 8

#define ESC "\033["

#define MODE_NONE         0
#define MODE_BOLD         1
#define MODE_DIM          2
#define MODE_UNDERLINE    4
#define MODE_BLINK        5
#define MODE_REVERSED     7
#define MODE_CONCEALED    8	
	
#define COL_FOREGROUND    3
#define COL_BACKGROUND    4

#define COL_BLACK         0
#define COL_RED           1
#define COL_GREEN         2
#define COL_YELLOW        3
#define COL_BLUE          4
#define COL_MAGENTA       5
#define COL_CYAN          6
#define COL_WHITE         7


#define RXBUFFSIZE 50
volatile uint8_t rxbuffer[RXBUFFSIZE];
volatile uint8_t rxi;
volatile uint8_t rxbuffovfl;

void p_menu(void);
void cls(void);
void set_cursorpos(uint8_t posx, uint8_t posy);
void clearsequence(uint8_t slength);
void setmode(uint8_t mode);
void printchar(PGM_P addr);
void setcolour(uint8_t fgbg, uint8_t colour);
void print_inputfield(void);
void echo(uint8_t val);



void pchar(uint8_t);
void pdigit(uint16_t);
void pstring(char*);
void phex(uint16_t);

	
#endif /* TERMINAL_H */
	
